package com.itheima;

/**
 * @Auther: shiquan
 * @Date: 2024/10/24 - 10 - 24 -11:43
 */
public class MathDemo1 {
    public static void main(String[] args) {
        /*
        public static int          abs(int a) 获取绝对值
        public static double       ceil(double a) 获取向上取整
        public static double      floor(double a) 获取向下取整
        public static int         round(float a) 四舍五入
        public static int         max(int a,int b) 获取两个数中的较大值
        public static double      pow(double a,double b) 返回a的b次幂
        public static  double    random()  返回值为double的随机数 范围[0,0，1.0]

         */
        // abs获取绝对值
        System.out.println(Math.abs(88));
        System.out.println(Math.abs(-88));

        //bug
        System.out.println(Math.ceil(12.34));//13.0
        System.out.println(Math.ceil(12.54));//13.0
        System.out.println(Math.ceil(-12.34)); //-12.0
        System.out.println(Math.ceil(-12.54));//-12.0

        //去尾法
        System.out.println(Math.floor(12.34)); //12.0
        System.out.println(Math.floor(12.54)); //12.0
        System.out.println(Math.floor(-12.34));//-13.0
        System.out.println(Math.floor(-12.54));//-13.0

        //四舍五入
        System.out.println(Math.round(12.34)); //12
        System.out.println(Math.round(12.54));//13
        System.out.println(Math.round(-12.34));//-12
        System.out.println(Math.round(-12.54));//-13

        //获取a的b次幂
        System.out.println(Math.pow(2,3));//8
        System.out.println(Math.pow(4,0.5));//2

        //开平方
        System.out.println(Math.sqrt(4)); //2




    }
}
